Control Method, Apparatus, and System for Collecting Traffic Statistics

ABSTRACT

A control method for collecting traffic statistics includes a control node obtains a statistics collection instruction, where the statistics collection instruction is used to instruct to collect traffic statistics of a target data flow, generates a traffic statistics collection policy according to the statistics collection instruction, where the traffic statistics collection policy includes a matching identifier of the target data flow, a first command, and a second command, and sends the traffic statistics collection policy to a forwarding node. The first command is used to instruct the forwarding node to set a traffic identifier for the target data flow based on the matching identifier, the second command is used to instruct the forwarding node to add traffic generated by a target packet to a traffic statistics collection result corresponding to the traffic identifier which is used to describe the traffic of the target data flow.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Patent ApplicationNo. PCT/CN2017/076964 filed on Mar. 16, 2017, which claims priority toChinese Patent Application No. 201610185868.2 filed on Mar. 29, 2016.The disclosures of the aforementioned applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

The present disclosure relates to the field of communicationstechnologies, and in particular, to a control method, apparatus, andsystem for collecting traffic statistics.

BACKGROUND

In a network, traffic statistics of a data flow between a customer andan autonomous system (AS) may be collected based on Border GatewayProtocol (BGP) route propagation. A manner for collecting trafficstatistics based on the BGP route propagation is also referred to as aBGP accounting technology.

In the conventional BGP accounting technology, if traffic statistics ofa data flow between a source AS and a destination AS need to becollected, an egress router configured to access the destination AS mayfirst set a specific community attribute for BGP routing information ofthe data flow, and then send, to an ingress router configured to accessthe source AS, the BGP routing information carrying the communityattribute. After receiving the BGP routing information, the ingressrouter selects a specific traffic index based on the community attributecarried in the BGP routing information, and correspondingly saves thetraffic index and the BGP routing information in a forwardinginformation base (FIB) of the ingress router. In this way, whenprocessing a packet of the data flow, the ingress router may collect thetraffic statistics of the data flow based on the traffic indexcorresponding to the BGP routing information in a forwarding table.

The inventor finds through research that in the conventional BGPaccounting technology, for the data flow whose traffic statistics needto be collected, a skilled person needs to configure the egress routerof the data flow such that the configured egress router can set thespecific community attribute in the BGP routing informationcorresponding to the data flow. In addition, the skilled person needs toconfigure the ingress router of the data flow such that the configuredingress router can set the traffic index for the data flow based on thecommunity attribute carried in the BGP routing information correspondingto the data flow, and collect the traffic statistics of the data flowbased on the traffic index. It can be learned that, if trafficstatistics of a large quantity of data flows in the network need to becollected, the skilled person needs to manually configure a largequantity of devices. As a result, the skilled person has heavy andcomplex configuration work.

SUMMARY

To resolve the foregoing technical problems, the application provides acontrol method, apparatus, and system for collecting traffic statisticsin order to reduce a quantity of devices that need to be manuallyconfigured by a skilled person for implementing traffic statisticscollection, thereby simplifying configuration work of the skilledperson.

According to a first aspect, an embodiment of the application provides acontrol method for collecting traffic statistics. The method includesobtaining, by a control node, a statistics collection instruction, wherethe statistics collection instruction is used to instruct to collecttraffic statistics of a target data flow, generating, by the controlnode, a traffic statistics collection policy according to the statisticscollection instruction, where the traffic statistics collection policyincludes a matching identifier of the target data flow, a first command,and a second command, the first command is used to instruct a forwardingnode to set a traffic identifier for the target data flow based on thematching identifier, the second command is used to instruct theforwarding node to add traffic generated by a target packet to a trafficstatistics collection result corresponding to the traffic identifier,the target packet belongs to the target data flow, and the trafficstatistics collection result corresponding to the traffic identifier isused to describe the traffic of the target data flow, and sending, bythe control node, the traffic statistics collection policy to theforwarding node.

Optionally, the traffic statistics collection policy is carried in a BGPFlow Specification (BGP FlowSpec) protocol packet, network layerreachability information (NLRI) of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec protocol packet carries the first command and thesecond command.

Optionally, the method further includes receiving, by the control node,statistics collection result report information sent by the forwardingnode, where the statistics collection result report information carriesan interface identifier of a target interface, the traffic identifier ofthe target data flow, and the traffic statistics collection resultcorresponding to the traffic identifier, and the target interface is aninterface that is on the forwarding node and that is configured toforward the target packet, and recording, by the control node, thetraffic statistics collection result corresponding to the trafficidentifier as a traffic statistics collection result of the target dataflow based on the statistics collection result report information.

Optionally, the statistics collection result report information iscarried in a first BGPLink State (BGP-LS) protocol packet.

Optionally, the statistics collection result report information is in aType-Length-Value (TLV) format. A type value used to indicate trafficstatistics collection is written in a type field of the statisticscollection result report information, a length value of the statisticscollection result report information is written in a length field of thestatistics collection result report information, and the interfaceidentifier, the traffic identifier, and the traffic statisticscollection result corresponding to the traffic identifier are written ina value field of the statistics collection result report information.

Optionally, the method further includes receiving, by the control node,first interface report information sent by the forwarding node, wherethe first interface report information carries an interface identifierof a target interface and an interface name of the target interface, andthe target interface is an interface that is on the forwarding node andthat is configured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thefirst interface report information, and the interface identifier and theinterface name are written in a value field of the first interfacereport information.

Optionally, the method further includes receiving, by the control node,second interface report information sent by the forwarding node, wherethe second interface report information carries an interface identifierof the target interface and interface description information of thetarget interface, and the target interface is an interface that is onthe forwarding node and that is configured to forward the target packet.

The second interface report information is carried in a third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the third optional information, and the interfaceidentifier and the interface description information are written in avalue field of the second interface report information.

According to a second aspect, an embodiment of the application providesa control method for collecting traffic statistics. The method includesreceiving, by a forwarding node, a traffic statistics collection policysent by a control node, where the traffic statistics collection policycarries a matching identifier of a target data flow, a first command,and a second command, the traffic statistics collection policy isgenerated by the control node according to a statistics collectioninstruction, and the statistics collection instruction is used toinstruct to collect traffic statistics of the target data flow, setting,by the forwarding node, a traffic identifier for the target data flowbased on the first command and the matching identifier, and adding, bythe forwarding node based on the second command, traffic generated by atarget packet to a traffic statistics collection result corresponding tothe traffic identifier.

The target packet belongs to the target data flow, and the trafficstatistics collection result corresponding to the traffic identifier isused to describe the traffic of the target data flow.

Optionally, the traffic statistics collection policy is carried in a BGPFlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec carries the first command and the second command.

Optionally, the setting, by the forwarding node, a traffic identifierfor the target data flow based on the first command and the matchingidentifier includes searching, by the forwarding node, for a forwardingentry corresponding to the matching identifier, and using the forwardingentry corresponding to the matching identifier as a forwarding entrycorresponding to the target data flow, and applying, by the forwardingnode to the forwarding entry corresponding to the target data flow, thetraffic identifier indicated by the first command.

Optionally, the method further includes sending, by the forwarding node,statistics collection result report information to the control node,where the statistics collection result report information carries aninterface identifier of a target interface, the traffic identifier ofthe target data flow, and the traffic statistics collection resultcorresponding to the traffic identifier, and the target interface is aninterface that is on the forwarding node and that is configured toforward the target packet.

Optionally, the statistics collection result report information iscarried in a first BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the statistics collection result reportinformation is written in a length field of the statistics collectionresult report information, and the interface identifier, the trafficidentifier, and the traffic statistics collection result correspondingto the traffic identifier are written in a value field of the statisticscollection result report information.

Optionally, the method further includes sending, by the forwarding node,first interface report information to the control node, where the firstinterface report information carries an interface identifier of a targetinterface and an interface name of the target interface, and the targetinterface is an interface that is on the forwarding node and that isconfigured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thefirst interface report information, and the interface identifier and theinterface name of the target interface are written in a value field ofthe first interface report information.

Optionally, the method further includes sending, by the forwarding node,second interface report information to the control node, where thesecond interface report carries an interface identifier of a targetinterface and interface description information of the target interface,and the target interface is an interface that is on the forwarding nodeand that is configured to forward the target packet.

The second interface report information is carried in the third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the third optional information, and the interfaceidentifier and the interface description information are written in avalue field of the second interface report information.

According to a third aspect, an embodiment of the application provides acontrol apparatus for collecting traffic statistics. A control node isdeployed in the apparatus, and the apparatus includes an obtaining unitconfigured to obtain a statistics collection instruction, where thestatistics collection instruction is used to instruct to collect trafficstatistics of a target data flow, a generation unit configured togenerate a traffic statistics collection policy according to thestatistics collection instruction, where the traffic statisticscollection policy includes a matching identifier of the target dataflow, a first command, and a second command, the first command is usedto instruct a forwarding node to set a traffic identifier for the targetdata flow based on the matching identifier, the second command is usedto instruct the forwarding node to add traffic generated by a targetpacket to a traffic statistics collection result corresponding to thetraffic identifier, the target packet belongs to the target data flow,and the traffic statistics collection result corresponding to thetraffic identifier is used to describe the traffic of the target dataflow, and a sending unit configured to send the traffic statisticscollection policy to the forwarding node.

Optionally, the traffic statistics collection policy is carried in a BGPFlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec protocol packet carries the first command and thesecond command.

Optionally, the apparatus further includes a first receiving unitconfigured to receive statistics collection result report informationsent by the forwarding node, where the statistics collection resultreport information carries an interface identifier of a targetinterface, the traffic identifier of the target data flow, and thetraffic statistics collection result corresponding to the trafficidentifier, and the target interface is an interface that is on theforwarding node and that is configured to forward the target packet, anda recording unit configured to record the traffic statistics collectionresult corresponding to the traffic identifier as a traffic statisticscollection result of the target data flow based on the statisticscollection result report information.

Optionally, the statistics collection result report information iscarried in a first BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the first optional information is writtenin a length field of the statistics collection result reportinformation, and the interface identifier, the traffic identifier, andthe traffic statistics collection result corresponding to the trafficidentifier are written in a value field of the statistics collectionresult report information.

Optionally, the apparatus further includes a second receiving unitconfigured to receive first interface report information sent by theforwarding node, where the first interface report information carries aninterface identifier of a target interface and an interface name of thetarget interface, and the target interface is an interface that is onthe forwarding node and that is configured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thesecond optional information, and the interface identifier and theinterface name of the target interface are written in a value field ofthe first interface report information.

Optionally, the apparatus further includes a third receiving unitconfigured to receive second interface report information sent by theforwarding node, where the second interface report information carriesan interface identifier of the target interface and interfacedescription information of the target interface, and the targetinterface is an interface that is on the forwarding node and that isconfigured to forward the target packet.

The second interface report information is carried in a third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the second interface report information, and theinterface identifier and the interface description information arewritten in a value field of the second interface report information.

According to a fourth aspect, an embodiment of the application providesa control apparatus for collecting traffic statistics. A forwarding nodeis deployed in the apparatus, and the apparatus includes a receivingunit configured to receive a traffic statistics collection policy sentby a control node, where the traffic statistics collection policycarries a matching identifier of a target data flow, a first command,and a second command, the traffic statistics collection policy isgenerated by the control node according to a statistics collectioninstruction, and the statistics collection instruction is used toinstruct to collect traffic statistics of the target data flow, asetting unit configured to set a traffic identifier for the target dataflow based on the first command and the matching identifier, and astatistics collection unit configured to add, based on the secondcommand, traffic generated by a target packet to a traffic statisticscollection result corresponding to the traffic identifier.

The target packet belongs to the target data flow, and the trafficstatistics collection result corresponding to the traffic identifier isused to describe the traffic of the target data flow.

Optionally, the traffic statistics collection policy is carried in a BGPFlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec carries the first command and the second command.

Optionally, the setting unit includes a searching subunit configured tosearch for a forwarding entry corresponding to the matching identifier,and use the forwarding entry corresponding to the matching identifier asa forwarding entry corresponding to the target data flow, and anapplication subunit configured to apply, to the forwarding entrycorresponding to the target data flow, the traffic identifier indicatedby the first command.

Optionally, the apparatus further includes a first sending unitconfigured to send statistics collection result report information tothe control node, where the statistics collection result reportinformation carries an interface identifier of a target interface, thetraffic identifier of the target data flow, and the traffic statisticscollection result corresponding to the traffic identifier, and thetarget interface is an interface that is on the forwarding node and thatis configured to forward the target packet.

The statistics collection result report information is carried in afirst BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the statistics collection result reportinformation may be written in a length field of the statisticscollection result report information, and the interface identifier, thetraffic identifier, and the traffic statistics collection resultcorresponding to the traffic identifier are written in a value field ofthe statistics collection result report information.

Optionally, the apparatus further includes a second sending unitconfigured to send first interface report information to the controlnode, where the first interface report information carries an interfaceidentifier of a target interface and an interface name of the targetinterface, and the target interface is an interface that is on theforwarding node and that is configured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thefirst interface report information, and the interface identifier and theinterface name of the target interface are written in a value field ofthe first interface report information.

Optionally, the apparatus further includes a third sending unitconfigured to send second interface report information to the controlnode, where the second interface report carries an interface identifierof a target interface and interface description information of thetarget interface, and the target interface is an interface that is onthe forwarding node and that is configured to forward the target packet.

The second interface report information is carried in the third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the second interface report information, and theinterface identifier and the interface description information arewritten in a value field of the second interface report information.

According to a fifth aspect, an embodiment of the application provides acontrol system for collecting traffic statistics. The system includes afirst network device and a second network device, the first networkdevice is the apparatus in any one of implementations of the thirdaspect, and the second network device is the apparatus in any one ofimplementations of the fourth aspect.

According to a sixth aspect, an embodiment of the application provides anetwork device. A control node is configured in the network device, andthe network device includes a processor, a memory, a network interface,and a bus system.

The bus system is configured to couple all hardware components of aphysical server together.

The network interface is configured to implement a communicationconnection between the physical server and at least one other networkelement.

The memory is configured to store a program instruction and data.

The processor is configured to read the instruction and the data thatare stored in the memory to perform the following operations obtaining astatistics collection instruction, where the statistics collectioninstruction is used to instruct to collect traffic statistics of atarget data flow, generating a traffic statistics collection policyaccording to the statistics collection instruction, where the trafficstatistics collection policy includes a matching identifier of thetarget data flow, a first command, and a second command, the firstcommand is used to instruct a forwarding node to set a trafficidentifier for the target data flow based on the matching identifier,the second command is used to instruct the forwarding node to addtraffic generated by a target packet to a traffic statistics collectionresult corresponding to the traffic identifier, the target packetbelongs to the target data flow, and the traffic statistics collectionresult corresponding to the traffic identifier is used to describe thetraffic of the target data flow, and sending the traffic statisticscollection policy to the forwarding node.

According to a seventh aspect, an embodiment of the application providesa network device. A forwarding node is configured in the network device,and the network device includes a processor, a memory, a networkinterface, and a bus system.

The bus system is configured to couple all hardware components of aphysical server together.

The network interface is configured to implement a communicationconnection between the physical server and at least one other networkelement.

The memory is configured to store a program instruction and data.

The processor is configured to read the instruction and the data thatare stored in the memory to perform the following operations ofreceiving a traffic statistics collection policy sent by a control node,where the traffic statistics collection policy carries a matchingidentifier of a target data flow, a first command, and a second command,the traffic statistics collection policy is generated by the controlnode according to a statistics collection instruction, and thestatistics collection instruction is used to instruct to collect trafficstatistics of the target data flow, setting a traffic identifier for thetarget data flow based on the first command and the matching identifier,and adding, based on the second command, traffic generated by a targetpacket to a traffic statistics collection result corresponding to thetraffic identifier.

The target packet belongs to the target data flow, and the trafficstatistics collection result corresponding to the traffic identifier isused to describe the traffic of the target data flow.

In comparison with other approaches, the embodiments of the applicationhave the following advantages.

In the embodiments of the application, if the traffic statistics of thetarget data flow need to be collected, the statistics collectioninstruction triggered by a user operation may be sent to the controlnode. In response to the statistics collection instruction, the controlnode may generate the traffic statistics collection policy and send thetraffic statistics collection policy to the forwarding node. Therefore,based on the commands carried in the traffic statistics collectionpolicy, the forwarding node may set the traffic identifier for thetarget data flow and collect the traffic statistics of the target dataflow into the traffic statistics collection result corresponding to thetraffic identifier. It can be learned that because the control nodedelivers the traffic statistics collection policy to all forwardingnodes in a centralized manner, a skilled person only needs to initiatethe statistics collection instruction to the control node such thattraffic statistics of a large quantity of data flows on all theforwarding nodes can be collected. Therefore, a quantity of devices thatneed to be manually configured by the skilled person is greatly reduced,thereby simplifying configuration work that needs to be of the skilledperson.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in some of the embodiments of thisapplication more clearly, the following briefly describes theaccompanying drawings describing some of the embodiments. Theaccompanying drawings in the following description show some embodimentsof this application, and a person of ordinary skill in the art may stillderive other drawings from these accompanying drawings without creativeefforts.

FIG. 1 is a schematic diagram of a system framework related to anapplication scenario according to an embodiment of the application;

FIG. 2 is a flowchart of a control method for collecting trafficstatistics according to an embodiment of the application;

FIG. 3 is a schematic diagram of an example format of interface reportinformation according to an embodiment of the application;

FIG. 4 is a schematic diagram of an example format of another type ofinterface report information according to an embodiment of theapplication;

FIG. 5 is a schematic diagram of an example format of statisticscollection result report information according to an embodiment of theapplication;

FIG. 6 is a flowchart of a control method for collecting trafficstatistics according to an embodiment of the application;

FIG. 7 is a schematic structural diagram of a control apparatus forcollecting traffic statistics according to an embodiment of theapplication;

FIG. 8 is a schematic structural diagram of a control apparatus forcollecting traffic statistics according to an embodiment of theapplication;

FIG. 9 is a schematic structural diagram of a control system forcollecting traffic statistics according to an embodiment of theapplication;

FIG. 10 is a schematic structural diagram of a network device accordingto an embodiment of the application; and

FIG. 11 is a schematic structural diagram of a network device accordingto an embodiment of the application.

DESCRIPTION OF EMBODIMENTS

To make a person skilled in the art understand the technical solutionsin this application better, the following clearly describes thetechnical solutions in the embodiments of this application withreference to the accompanying drawings in the embodiments of thisapplication. The described embodiments are merely a part rather than allof the embodiments of this application. All other embodiments obtainedby a person of ordinary skill in the art based on the embodiments ofthis application without creative efforts shall fall within theprotection scope of this application.

A target data flow between a source AS and a destination AS, an ingressrouter configured to access the source AS collects traffic statistics ofthe target data flow. Further, the ingress router has a traffic indexcorresponding to the target data flow, and the ingress router collectsthe traffic statistics of the target data flow into a traffic statisticscollection result corresponding to the traffic index. In a conventionalBGP accounting technology, to make the ingress router have the trafficindex corresponding to the target data flow, both the ingress router andan egress router that is configured to access the destination AS need tobe manually configured by a skilled person. After being manuallyconfigured by the skilled person, the egress router sets a specificcommunity attribute in BGP routing information of the target data flowsuch that the egress router sends, to the ingress router, the BGProuting information carrying the community attribute. In addition, afterbeing manually configured by the skilled person and receiving the BGProuting information, the ingress router sets the corresponding trafficindex for the target data flow based on the community attribute carriedin the BGP routing information. If traffic statistics of a largequantity of data flows in a network need to be collected, the skilledperson needs to manually configure an ingress router and an egressrouter for each data flow. It can be learned that the skilled personneeds to manually configure an excessively large quantity of devices. Asa result, the skilled person has heavy and complex configuration work.

To resolve the foregoing problem, the embodiments of the applicationprovide a control method, apparatus, and system for collecting trafficstatistics. If traffic statistics of a target data flow need to becollected, a control node may obtain a statistics collection instructiontriggered by a user operation. In response to the statistics collectioninstruction, the control node may generate a traffic statisticscollection policy and send the traffic statistics collection policy to aforwarding node. Therefore, based on a command carried in the trafficstatistics collection policy, the forwarding node may set a trafficidentifier for the target data flow and collect the traffic statisticsof the target data flow into a traffic statistics collection resultcorresponding to the traffic identifier. It can be learned that becausethe control node delivers the traffic statistics collection policy toall forwarding nodes in a centralized manner, a skilled person onlyneeds to initiate the statistics collection instruction to the controlnode such that traffic statistics of a large quantity of data flows onall the forwarding nodes can be collected. Therefore, a quantity ofdevices that need to be manually configured by the skilled person isgreatly reduced, thereby simplifying configuration work that needs to beof the skilled person.

For example, one of application scenarios of the embodiments of theapplication may be applied to a network system shown in FIG. 1. Acontrol node and a forwarding node are deployed in the network system.The control node obtains a statistics collection instruction, and thestatistics collection instruction is used to instruct to collect trafficstatistics of a target data flow. The control node generates a trafficstatistics collection policy according to the statistics collectioninstruction, and the traffic statistics collection policy includes amatching identifier of the target data flow, a first command, and asecond command. The control node sends the traffic statistics collectionpolicy to the forwarding node. After the forwarding node receives thetraffic statistics collection policy sent by the control node, theforwarding node sets a traffic identifier for the target data flow basedon the first command and the matching identifier, and adds, based on thesecond command, traffic generated by a target packet to a trafficstatistics collection result corresponding to the traffic identifier.The target packet belongs to the target data flow, and the trafficstatistics collection result corresponding to the traffic identifier isused to describe the traffic of the target data flow.

It may be understood that, for example, physical devices in the networksystem may include a plurality of forwarding devices 102. For anotherexample, physical devices in the network system may include a controller101 and a plurality of forwarding devices 102.

In an example, the control node may be implemented as an independentphysical device such as an independent controller 101. Similarly, theforwarding node may be implemented as an independent physical devicesuch as any independent forwarding device 102, where each independentforwarding device 102 is a forwarding node.

In another example, the control node may be implemented as a programrunning on a physical device, for example, a program running on thecontroller 101 or a program running on any forwarding device 102.Similarly, the forwarding node may be implemented as a program runningon a physical device, for example, a program running on a forwardingdevice 102. It may be understood that one physical device runs only oneprogram. For example, the controller 101 runs only the control node, andeach forwarding device 102 runs only one forwarding node. Alternatively,a plurality of different programs may run on a same forwarding device102. For example, a plurality of different forwarding nodes may run on asame forwarding device 102. For another example, the control node andthe forwarding node may run on a same forwarding device 102.

In still another example, the control node may be implemented as avirtual machine deployed on a physical device, for example, a virtualmachine deployed on the controller 101 or a virtual machine running on aforwarding device 102. Similarly, the forwarding node may be implementedas a virtual machine deployed on a physical device, for example, avirtual machine deployed on a forwarding device 102. It may beunderstood that one physical device may be completely occupied by onevirtual machine. For example, the controller 101 is completely occupiedby the control node, and each forwarding device 102 is completelyoccupied by a forwarding node. Alternatively, one physical device may bejointly occupied by a plurality of virtual machines. For example, a sameforwarding device 102 is jointly occupied by a plurality of forwardingnodes. For another example, a same forwarding device 102 is jointlyoccupied by the forwarding node and the control node. In this case, thecontroller 101 and the forwarding devices 102 may be general-purposephysical servers.

It should be noted that the foregoing application scenario is shown onlyto facilitate understanding of the embodiments of the application, butis not intended to limit the technical solutions provided in theembodiments of application.

With reference to accompanying drawings, the following describes indetail specific implementations of the control method, apparatus, andsystem for collecting traffic statistics in the application usingembodiments.

FIG. 2 is a flowchart of a control method for collecting trafficstatistics according to an embodiment of the application. The method isdescribed from a perspective of a control node in this embodiment. Inthis embodiment, for example, the method may include the followingsteps.

Step 201: The control node obtains a statistics collection instruction,where the statistics collection instruction is used to instruct tocollect traffic statistics of a target data flow.

If the traffic statistics of the target data flow need to be collected,a skilled person may initiate the statistics collection instruction tothe control node using a device used by the skilled person. Afterobtaining the statistics collection request, the control nodedetermines, according to the statistics collection instruction, thetarget data flow corresponding to the statistics collection instruction.The statistics collection instruction is used to instruct to collect thetraffic statistics of the target data flow. Further, the statisticscollection instruction is used to instruct the control node to send atraffic statistics collection policy corresponding to the target dataflow to a forwarding node such that the forwarding node collects thetraffic statistics of the target data flow based on the instruction ofthe traffic statistics collection policy.

In some implementations, the physical device used by the skilled personand a physical device in which the control node is located may be a samephysical device. For example, the skilled person may perform anoperation on a physical controller in which the control node is locatedsuch that the physical controller generates the statistics collectioninstruction and internally transmits the statistics collectioninstruction to the control node. In some other implementations, thephysical device used by the skilled person and a physical device inwhich the control node is located may be different physical devices. Forexample, the skilled person performs an operation on a terminal deviceof the skilled person, and in response to the operation of the skilledperson, the terminal device of the skilled person generates thestatistics collection instruction and sends the statistics collectioninstruction to the control node on a physical controller.

In addition, the statistics collection instruction may be automaticallyinitiated to the control node according to a pre-configured statisticscollection rule. For example, the physical controller in which thecontrol node is located has the pre-configured statistics collectionrule. If a trigger occasion indicated by the statistics collection rulefor the statistics collection instruction is met, the physicalcontroller may generate the statistics collection instruction andinternally transmit the statistics collection instruction to the controlnode.

It may be understood that the statistics collection instruction mayinstruct the control node to select a target interface to collect thetraffic statistics of the target data flow, and the target interface isan interface configured to forward the target data flow. If thestatistics collection instruction indicates the target interface, thecontrol node may deliver the traffic statistics collection policycorresponding to the target data flow to the forwarding node on whichthe target interface is located such that the forwarding node cancollect the traffic statistics of the target data flow on the targetinterface.

It should be noted that the forwarding node may report relatedinformation of an interface of the forwarding node to the control nodein advance such that the control node feeds back the information to theskilled person. The skilled person may initiate, to the control nodebased on the interface information reported to the control node, thestatistics collection instruction used to instruct to collect thetraffic statistics of the target data flow on the target interface.Alternatively, the skilled person may set the statistics collection rulebased on the interface information reported to the control node, and thestatistics collection rule is used to trigger, on a specific occasion,the statistics collection instruction used to instruct to collect thetraffic statistics of the target data flow on the target interface.

In some implementations, the interface information reported by theforwarding node to the control node may include an interface identifierand an interface name of the interface of the forwarding node. Further,before step 201, for example, the method in this embodiment may furtherinclude receiving, by the control node, first interface reportinformation sent by the forwarding node, where the first interfacereport information carries an interface identifier of a target interfaceand an interface name of the target interface, and the target interfaceis an interface that is on the forwarding node and that is configured toforward the target packet.

For example, the first interface report information may be reportedusing a BGP-LS protocol packet. The first interface report informationis carried in a first BGP-LS protocol packet sent by the forwarding nodeto the control node. Further, as shown in FIG. 3, for example, the firstinterface report information carried in the first BGP-LS protocol packetmay be in a TLV format. A type value used to indicate the interface namemay be written in a type field, for example, “TBD1 (Interface Name)” inFIG. 3. A length value of the first interface report information may bewritten in a length field, which occupies 2 bytes, for example, “Length(2 Octets)” in FIG. 3. The interface identifier may be written in avalue field, which occupies 4 bytes, for example, “Interface Index (4Octets)” in FIG. 3. The interface name may be written in another valuefield, which occupies a maximum of 64 bytes, for example, “InterfaceName (variable Octets)” in FIG. 3. The interface identifier may be aninterface index, that is, an index value allocated by the forwardingnode to the interface of the forwarding node. A same forwarding nodeallocates different index values to different interfaces. For example,the interface name may be a character string including American StandardCode for Information Interchange (ASCII) characters, and the characterstring ends with ‘\0’.

In some other implementations, the interface information reported by theforwarding node to the control node may include an interface identifierand interface description information of the interface of the forwardingnode. Further, before step 201, for example, the method in thisembodiment may further include receiving, by the control node, secondinterface report information sent by the forwarding node, where thesecond interface report information carries an interface identifier ofthe target interface and interface description information of the targetinterface, and the target interface is an interface that is on theforwarding node and that is configured to forward the target packet. Theinterface description information is information used to describe aninterface feature. For example, interface description information of aninterface on a router A may be “interface connecting a router A to arouter B”, may be “interface connecting a router A to a user a”, or maybe “100G interface connecting to a user b for a router A”.

For example, the second interface report information may be reportedusing a BGP-LS protocol packet. The second interface report informationis carried in a second BGP-LS protocol packet sent by the forwardingnode to the control node. Further, as shown in FIG. 4, for example, thesecond interface report information carried in the second BGP-LSprotocol packet may be in a TLV format. A type value used to indicatethe interface description information may be written in a type field,for example, “TBD 2 (Interface Description)” in FIG. 4. A length valueof the second interface report information may be written in a lengthfield, which occupies 2 bytes, for example, “Length (2 Octets)” in FIG.4. The interface identifier may be written in a value field, whichoccupies 4 bytes, for example, “Interface Index (4 Octets)” in FIG. 4.The interface description information may be written in another valuefield, which occupies a maximum of 256 bytes, for example, “InterfaceDescription (variable Octets)” in FIG. 4. The interface identifier maybe an interface index, that is, an index value allocated by theforwarding node to the interface of the forwarding node. A sameforwarding node allocates different index values to differentinterfaces. For example, the interface description information may be acharacter string including ASCII characters, and the character stringends with ‘\0’.

In still some other implementations, the interface information reportedby the forwarding node to the control node may include an interfaceidentifier, an interface name, and interface description information ofthe interface of the forwarding node. Further, before step 201, forexample, the method in this embodiment may further include receiving, bythe control node, the first interface report information sent by theforwarding node, and receiving, by the control node, the secondinterface report information sent by the forwarding node.

Step 202: The control node generates a traffic statistics collectionpolicy according to the statistics collection instruction, where thetraffic statistics collection policy includes a matching identifier ofthe target data flow, a first command, and a second command, the firstcommand is used to instruct a forwarding node to set a trafficidentifier for the target data flow based on the matching identifier,the second command is used to instruct the forwarding node to addtraffic generated by a target packet to a traffic statistics collectionresult corresponding to the traffic identifier, the target packetbelongs to the target data flow, and the traffic statistics collectionresult corresponding to the traffic identifier is used to describe thetraffic of the target data flow.

Further, the statistics collection instruction indicates the target dataflow and the target interface. Therefore, after receiving the statisticscollection instruction, the control node may generate, according to thestatistics collection instruction, the traffic statistics collectionpolicy corresponding to the target data flow, and send the trafficstatistics collection policy to the forwarding node on which the targetinterface is located.

The traffic statistics collection policy is used to trigger theforwarding node to collect the traffic statistics of the target dataflow. Further, the traffic statistics collection policy includes thematching identifier of the target data flow, and the forwarding node canidentify the target data flow based on the matching identifier. Forexample, the matching identifier may be an AS number list, a communitylist, an extended community list (Ext-Community List), or an InternetProtocol (IP) version 4 (IPv4) prefix list and/or an IP version 6 (IPv6)prefix list. In addition, the traffic statistics collection policyfurther includes the first command and the second command. Theforwarding node sets the traffic identifier for the identified targetdata flow based on the first command. When forwarding the target packetthat belongs to the target data flow, the forwarding node adds, based onthe second command, the traffic generated by the target packet to thetraffic statistics collection result corresponding to the trafficidentifier that has been set.

In some implementations, for example, the traffic statistics collectionpolicy may be delivered using a BGP FlowSpec protocol packet. Thetraffic statistics collection policy is carried in a BGP FlowSpecprotocol packet delivered by the control node to the forwarding node.Further, the BGP FlowSpec protocol packet carries NLRI and an extendedcommunity attribute. The NLRI carries the matching identifier, and theextended community attribute carries the first command and the secondcommand. For example, the first command carried in the extendedcommunity attribute may be “set-traffic-index”. For example, the secondcommand carried in the extended community attribute may be“specify-interface-index”.

Step 203: The control node sends the traffic statistics collectionpolicy to the forwarding node.

After the forwarding node receives the traffic statistics collectionpolicy, the forwarding node sets the traffic identifier for the targetdata flow based on the first command in the traffic statisticscollection policy. For example, a specific manner for setting thetraffic identifier may be as follows. The forwarding node searches for aforwarding entry corresponding to the matching identifier, and uses theforwarding entry corresponding to the matching identifier as aforwarding entry corresponding to the target data flow, and theforwarding node applies, to the forwarding entry corresponding to thetarget data flow, the traffic identifier indicated by the first command.For example, a manner for applying the traffic identifier to theforwarding entry may be adding the traffic identifier to the forwardingentry corresponding to the target data flow. The traffic identifier maybe an index value allocated to the target data flow, namely, a trafficindex.

After the forwarding node sets the traffic identifier for the targetdata flow, when forwarding the target packet that belongs to the targetdata flow, the forwarding node adds, based on the second command in thetraffic statistics collection policy, the traffic generated by thetarget packet to the traffic statistics collection result correspondingto the traffic identifier that has been set. Further, based on theinstruction of the second command, the forwarding node may configure acommand line for the target interface indicated by the trafficstatistics collection policy. The command line is used to enable thetarget interface to collect the traffic statistics of the target dataflow. After configuring the command line, if the forwarding nodereceives the target packet that belongs to the target data flow, theforwarding node searches for the forwarding entry corresponding to thetarget data flow to forward the target packet. After finding theforwarding entry and forwarding the target packet based on theforwarding entry, the forwarding node identifies the command linecorresponding to the target interface configured to forward the targetpacket, and the forwarding node also identifies the traffic identifierin the forwarding entry. Based on the instruction of the command line,the forwarding node adds the traffic generated by the target packet tothe traffic statistics collection result corresponding to the trafficidentifier.

In some implementations of this embodiment, the traffic statisticscollection result obtained by collecting the traffic statistics of thetarget data flow on the forwarding node may be uploaded to the controlnode. In this way, traffic statistics collection results of all dataflows may be gathered on the control node and fed back to the skilledperson. Further, after step 203, for example, the method in thisembodiment may further include receiving, by the control node,statistics collection result report information sent by the forwardingnode, and recording, by the control node, the traffic statisticscollection result corresponding to the traffic identifier as a trafficstatistics collection result of the target data flow based on thestatistics collection result report information. The statisticscollection result report information may carry an interface identifierof a target interface, the traffic identifier of the target data flow,and the traffic statistics collection result corresponding to thetraffic identifier. The target interface is an interface that is on theforwarding node and that is configured to forward the target packet.After the control node receives the statistics collection result reportinformation, the control node determines, based on the interfaceidentifier and the traffic identifier in the statistics collectionresult report information, that the statistics collection result reportinformation is used to report the traffic statistics collection resultof the target data flow in order to record the traffic statisticscollection result in the statistics collection result report informationas the traffic statistics collection result of the target data flow.

For example, the statistics collection result report information may bereported using a BGP-LS protocol packet. The statistics collectionresult report information is carried in a third BGP-LS protocol packetsent by the forwarding node to the control node. Further, as shown inFIG. 5, for example, the statistics collection result report informationcarried in the third BGP-LS protocol packet may be in a TLV format. Atype value used to indicate traffic statistics collection may be writtenin a type field, for example, “TBD 3 (Traffic Collection)” in FIG. 5. Alength value of third optional information may be written in a lengthfield, which occupies 2 bytes, for example, “Length (2 Octets)” in FIG.5. The interface identifier may be written in a value field, whichoccupies 4 bytes, for example, “Interface Index (4 Octets)” in FIG. 5.The traffic identifier may be written in another value field, whichoccupies 4 bytes, for example, “Traffic Index (4 Octets)” in FIG. 5. Amost significant bit of the statistics collection result in a unit ofbyte may be written in still another value field, which occupies 4bytes, for example, “Bytes Counter 1 (4 Octets)” in FIG. 5. A leastsignificant bit of the statistics collection result in a unit of bytemay be written in still another value field, which occupies 4 bytes, forexample, “Bytes Counter 2 (4 Octets)” in FIG. 5. A most significant bitof the statistics collection result in a unit of packet may be writtenin still another value field, for example, “Packets Counter 1 (4Octets)” in FIG. 5. A least significant bit of the statistics collectionresult in a unit of packet may be written in still another value field,which occupies 4 bytes, for example, “Packets Counter 2 (4 Octets)” inFIG. 5.

In this embodiment, if the traffic statistics of the target data flowneed to be collected, the statistics collection instruction triggered bya user operation may be sent to the control node. In response to thestatistics collection instruction, the control node may generate thetraffic statistics collection policy and send the traffic statisticscollection policy to the forwarding node. Therefore, based on thecommands carried in the traffic statistics collection policy, theforwarding node may set the traffic identifier for the target data flowand collect the traffic statistics of the target data flow into thetraffic statistics collection result corresponding to the trafficidentifier. It can be learned that because the control node delivers thetraffic statistics collection policy to all forwarding nodes in acentralized manner, the skilled person only needs to initiate thestatistics collection instruction to the control node such that trafficstatistics of a large quantity of data flows on all the forwarding nodescan be collected. Therefore, a quantity of devices that need to bemanually configured by the skilled person is greatly reduced, therebysimplifying configuration work that needs to be of the skilled person.

FIG. 6 is a flowchart of a control method for collecting trafficstatistics according to an embodiment of the application. The method isdescribed from a perspective of a forwarding node in this embodiment. Inthis embodiment, for example, the method may include the followingsteps.

Step 601: The forwarding node receives a traffic statistics collectionpolicy sent by a control node, where the traffic statistics collectionpolicy carries a matching identifier of a target data flow, a firstcommand, and a second command, the traffic statistics collection policyis generated by the control node according to a statistics collectioninstruction, and the statistics collection instruction is used toinstruct to collect traffic statistics of the target data flow.

Step 602: The forwarding node sets a traffic identifier for the targetdata flow based on the first command and the matching identifier.

Step 603: The forwarding node adds, based on the second command, trafficgenerated by a target packet to a traffic statistics collection resultcorresponding to the traffic identifier, where the target packet belongsto the target data flow, and the traffic statistics collection resultcorresponding to the traffic identifier is used to describe the trafficof the target data flow.

Optionally, the traffic statistics collection policy is carried in a BGPFlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec carries the first command and the second command.

Optionally, step 602 may include searching, by the forwarding node, fora forwarding entry corresponding to the matching identifier, and usingthe forwarding entry corresponding to the matching identifier as aforwarding entry corresponding to the target data flow, and applying, bythe forwarding node to the forwarding entry corresponding to the targetdata flow, the traffic identifier indicated by the first command.

Optionally, the method may further include sending, by the forwardingnode, statistics collection result report information to the controlnode, where the statistics collection result report information carriesan interface identifier of a target interface, the traffic identifier ofthe target data flow, and the traffic statistics collection resultcorresponding to the traffic identifier, and the target interface is aninterface that is on the forwarding node and that is configured toforward the target packet.

Optionally, the statistics collection result report information iscarried in a first BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the statistics collection result reportinformation is written in a length field of the statistics collectionresult report information, and the interface identifier, the trafficidentifier, and the traffic statistics collection result correspondingto the traffic identifier are written in a value field of the statisticscollection result report information.

Optionally, the method further includes sending, by the forwarding node,first interface report information to the control node, where the firstinterface report information carries an interface identifier of a targetinterface and an interface name of the target interface, and the targetinterface is an interface that is on the forwarding node and that isconfigured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thefirst interface report information, and the interface identifier and theinterface name are written in a value field of the first interfacereport information.

Optionally, the method may further include sending, by the forwardingnode, second interface report information to the control node, where thesecond interface report carries an interface identifier of a targetinterface and interface description information of the target interface,and the target interface is an interface that is on the forwarding nodeand that is configured to forward the target packet.

The second interface report information is carried in the third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the third optional information, and the interfaceidentifier and the interface description information are written in avalue field of the second interface report information.

It should be noted that the forwarding node in this embodiment of theapplication is equivalent to the forwarding node mentioned in theembodiment shown in FIG. 2. For various specific implementations of themethod performed by the forwarding node in this embodiment, refer to adetailed description of the embodiment shown in FIG. 2. Details are notdescribed herein again.

In this embodiment, if the traffic statistics of the target data flowneed to be collected, the statistics collection instruction triggered bya user operation may be sent to the control node. In response to thestatistics collection instruction, the control node may generate thetraffic statistics collection policy and send the traffic statisticscollection policy to the forwarding node. Therefore, based on thecommands carried in the traffic statistics collection policy, theforwarding node may set the traffic identifier for the target data flowand collect the traffic statistics of the target data flow into thetraffic statistics collection result corresponding to the trafficidentifier. It can be learned that because the control node delivers thetraffic statistics collection policy to all forwarding nodes in acentralized manner, a skilled person only needs to initiate thestatistics collection instruction to the control node such that trafficstatistics of a large quantity of data flows on all the forwarding nodescan be collected. Therefore, a quantity of devices that need to bemanually configured by the skilled person is greatly reduced, therebysimplifying configuration work that needs to be of the skilled person.

FIG. 7 is a schematic structural diagram of a control apparatus 700 forcollecting traffic statistics according to an embodiment of theapplication. In this embodiment, a control node is deployed in theapparatus 700. For example, the apparatus 700 may include an obtainingunit 701 configured to obtain a statistics collection instruction, wherethe statistics collection instruction is used to instruct to collecttraffic statistics of a target data flow, a generation unit 702configured to generate a traffic statistics collection policy accordingto the statistics collection instruction, where the traffic statisticscollection policy includes a matching identifier of the target dataflow, a first command, and a second command, the first command is usedto instruct a forwarding node to set a traffic identifier for the targetdata flow based on the matching identifier, the second command is usedto instruct the forwarding node to add traffic generated by a targetpacket to a traffic statistics collection result corresponding to thetraffic identifier, the target packet belongs to the target data flow,and the traffic statistics collection result corresponding to thetraffic identifier is used to describe the traffic of the target dataflow, and a sending unit 703 configured to send the traffic statisticscollection policy to the forwarding node.

For example, the apparatus 700 shown in FIG. 7 may be configured toperform the method shown in FIG. 2. Further, the obtaining unit 701 maybe configured to perform step 201 in FIG. 2. The generation unit 702 maybe configured to perform step 202 in FIG. 2. The sending unit 703 may beconfigured to perform step 203 in FIG. 2.

Optionally, the traffic statistics collection policy may be carried in aBGP FlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec protocol packet carries the first command and thesecond command.

Optionally, the apparatus 700 may further include a first receiving unit(not shown) configured to receive statistics collection result reportinformation sent by the forwarding node, where the statistics collectionresult report information carries an interface identifier of a targetinterface, the traffic identifier of the target data flow, and thetraffic statistics collection result corresponding to the trafficidentifier, and the target interface is an interface that is on theforwarding node and that is configured to forward the target packet, anda recording unit (not shown) configured to record the traffic statisticscollection result corresponding to the traffic identifier as a trafficstatistics collection result of the target data flow based on thestatistics collection result report information.

Optionally, the statistics collection result report information may becarried in a first BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the first optional information is writtenin a length field of the statistics collection result reportinformation, and the interface identifier, the traffic identifier, andthe traffic statistics collection result corresponding to the trafficidentifier are written in a value field of the statistics collectionresult report information.

Optionally, the apparatus 700 may further include a second receivingunit (not shown) configured to receive first interface reportinformation sent by the forwarding node, where the first interfacereport information carries an interface identifier of a target interfaceand an interface name of the target interface, and the target interfaceis an interface that is on the forwarding node and that is configured toforward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thesecond optional information, and the interface identifier and theinterface name of the target interface are written in a value field ofthe first interface report information.

Optionally, the apparatus 700 may further include a third receiving unit(not shown) configured to receive second interface report informationsent by the forwarding node, where the second interface reportinformation carries an interface identifier of the target interface andinterface description information of the target interface, and thetarget interface is an interface that is on the forwarding node and thatis configured to forward the target packet.

The second interface report information is carried in a third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the second interface report information, and theinterface identifier and the interface description information arewritten in a value field of the second interface report information.

It should be noted that the control node in the embodiment shown in FIG.2 is deployed in the apparatus 700 in this embodiment. For variousspecific implementations of the apparatus 700 in this embodiment, referto a detailed description of the control node in the embodiment shown inFIG. 2. Details are not described herein again.

In this embodiment, if the traffic statistics of the target data flowneed to be collected, the statistics collection instruction triggered bya user operation may be sent to the control node. In response to thestatistics collection instruction, the control node may generate thetraffic statistics collection policy and send the traffic statisticscollection policy to the forwarding node. Therefore, based on thecommands carried in the traffic statistics collection policy, theforwarding node may set the traffic identifier for the target data flowand collect the traffic statistics of the target data flow into thetraffic statistics collection result corresponding to the trafficidentifier. It can be learned that because the control node delivers thetraffic statistics collection policy to all forwarding nodes in acentralized manner, a skilled person only needs to initiate thestatistics collection instruction to the control node such that trafficstatistics of a large quantity of data flows on all the forwarding nodescan be collected. Therefore, a quantity of devices that need to bemanually configured by the skilled person is greatly reduced, therebysimplifying configuration work that needs to be of the skilled person.

FIG. 8 is a schematic structural diagram of a control apparatus 800 forcollecting traffic statistics according to an embodiment of theapplication. In this embodiment, a forwarding node is deployed in theapparatus 800. For example, the apparatus 800 may include a receivingunit 801 configured to receive a traffic statistics collection policysent by a control node, where the traffic statistics collection policycarries a matching identifier of a target data flow, a first command,and a second command, the traffic statistics collection policy isgenerated by the control node according to a statistics collectioninstruction, and the statistics collection instruction is used toinstruct to collect traffic statistics of the target data flow, asetting unit 802 configured to set a traffic identifier for the targetdata flow based on the first command and the matching identifier, and astatistics collection unit 803 configured to add, based on the secondcommand, traffic generated by a target packet to a traffic statisticscollection result corresponding to the traffic identifier.

The target packet belongs to the target data flow, and the trafficstatistics collection result corresponding to the traffic identifier isused to describe the traffic of the target data flow.

For example, the apparatus 800 shown in FIG. 8 may be configured toperform the method shown in FIG. 6. Further, the receiving unit 801 maybe configured to perform step 601 in FIG. 6. The setting unit 802 may beconfigured to perform step 602 in FIG. 6. The statistics collection unit803 may be configured to perform step 603 in FIG. 6.

Optionally, the traffic statistics collection policy may be carried in aBGP FlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec carries the first command and the second command.

Optionally, the setting unit 802 may include a searching subunit (notshown) configured to search for a forwarding entry corresponding to thematching identifier, and use the forwarding entry corresponding to thematching identifier as a forwarding entry corresponding to the targetdata flow, and an application subunit (not shown) configured to apply,to the forwarding entry corresponding to the target data flow, thetraffic identifier indicated by the first command.

Optionally, the apparatus 800 further includes a first sending unit (notshown) configured to send statistics collection result reportinformation to the control node, where the statistics collection resultreport information carries an interface identifier of a targetinterface, the traffic identifier of the target data flow, and thetraffic statistics collection result corresponding to the trafficidentifier, and the target interface is an interface that is on theforwarding node and that is configured to forward the target packet.

Optionally, the statistics collection result report information may becarried in a first BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the statistics collection result reportinformation may be written in a length field of the statisticscollection result report information, and the interface identifier, thetraffic identifier, and the traffic statistics collection resultcorresponding to the traffic identifier are written in a value field ofthe statistics collection result report information.

Optionally, the apparatus 800 may further include a second sending unit(not shown) configured to send first interface report information to thecontrol node, where the first interface report information carries aninterface identifier of a target interface and an interface name of thetarget interface, and the target interface is an interface that is onthe forwarding node and that is configured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thefirst interface report information, and the interface identifier and theinterface name of the target interface are written in a value field ofthe first interface report information.

Optionally, the apparatus 800 may further include a third sending unit(not shown) configured to send second interface report information tothe control node, where the second interface report carries an interfaceidentifier of a target interface and interface description informationof the target interface, and the target interface is an interface thatis on the forwarding node and that is configured to forward the targetpacket.

The second interface report information is carried in the third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the second interface report information, and theinterface identifier and the interface description information arewritten in a value field of the second interface report information.

It should be noted that the forwarding node in the embodiment shown inFIG. 2 is deployed in the apparatus 800 in this embodiment. For variousspecific implementations of the apparatus 800 in this embodiment, referto a detailed description of the forwarding node in the embodiment shownin FIG. 2. Details are not described herein again.

In this embodiment, if the traffic statistics of the target data flowneed to be collected, the statistics collection instruction triggered bya user operation may be sent to the control node. In response to thestatistics collection instruction, the control node may generate thetraffic statistics collection policy and send the traffic statisticscollection policy to the forwarding node. Therefore, based on thecommands carried in the traffic statistics collection policy, theforwarding node may set the traffic identifier for the target data flowand collect the traffic statistics of the target data flow into thetraffic statistics collection result corresponding to the trafficidentifier. It can be learned that because the control node delivers thetraffic statistics collection policy to all forwarding nodes in acentralized manner, a skilled person only needs to initiate thestatistics collection instruction to the control node such that trafficstatistics of a large quantity of data flows on all the forwarding nodescan be collected. Therefore, a quantity of devices that need to bemanually configured by the skilled person is greatly reduced, therebysimplifying configuration work that needs to be of the skilled person.

FIG. 9 is a schematic structural diagram of a control system forcollecting traffic statistics according to an embodiment of theapplication. In this embodiment, the system includes a first networkdevice 902 and a second network device 902. The first network device 901may be the apparatus 700 in any one of the foregoing implementations,and the second network device 902 may be the apparatus 800 in any one ofthe foregoing implementations.

It should be noted that the control node mentioned in the embodimentshown in FIG. 2 is configured in the first network device 901 in thisembodiment, and the forwarding node mentioned in the embodiment shown inFIG. 2 is configured in the second network device 902 in thisembodiment. For various specific implementations of the first networkdevice 901 and the second network device 902 in this embodiment, referto detailed descriptions of the embodiment shown in FIG. 2. Details arenot described in this embodiment again.

In this embodiment, if traffic statistics of a target data flow need tobe collected, a statistics collection instruction triggered by a useroperation may be sent to the control node. In response to the statisticscollection instruction, the control node may generate a trafficstatistics collection policy and send the traffic statistics collectionpolicy to the forwarding node. Therefore, based on a command carried inthe traffic statistics collection policy, the forwarding node may set atraffic identifier for the target data flow and collect the trafficstatistics of the target data flow into a traffic statistics collectionresult corresponding to the traffic identifier. It can be learned thatbecause the control node delivers the traffic statistics collectionpolicy to all forwarding nodes in a centralized manner, a skilled persononly needs to initiate the statistics collection instruction to thecontrol node such that traffic statistics of a large quantity of dataflows on all the forwarding nodes can be collected. Therefore, aquantity of devices that need to be manually configured by the skilledperson is greatly reduced, thereby simplifying configuration work thatneeds to be of the skilled person.

FIG. 10 is a schematic structural diagram of a network device 1000according to an embodiment of the application. The control node in theembodiment shown in FIG. 2 is deployed in the network device 1000 inthis embodiment, and the network device 1000 may be configured toperform the method in the embodiment shown in FIG. 2. The network device1000 includes a processor 1001, a memory 1002, a network interface 1003,and a bus system 1004.

The bus system 1004 is configured to couple all hardware components ofthe network device 1000 together.

The network interface 1003 is configured to implement a communicationconnection between the network device 1000 and at least one othernetwork element through the Internet, a wide area network, a local areanetwork, a metropolitan area network, or another manner.

The memory 1002 is configured to store a program instruction, operatingsystem and data.

The processor 1001 is configured to read the instruction and the datathat are stored in the memory 1002 in order to perform the followingoperations of obtaining a statistics collection instruction, where thestatistics collection instruction is used to instruct to collect trafficstatistics of a target data flow, generating a traffic statisticscollection policy according to the statistics collection instruction,where the traffic statistics collection policy includes a matchingidentifier of the target data flow, a first command, and a secondcommand, the first command is used to instruct a forwarding node to seta traffic identifier for the target data flow based on the matchingidentifier, the second command is used to instruct the forwarding nodeto add traffic generated by a target packet to a traffic statisticscollection result corresponding to the traffic identifier, the targetpacket belongs to the target data flow, and the traffic statisticscollection result corresponding to the traffic identifier is used todescribe the traffic of the target data flow, and sending the trafficstatistics collection policy to the forwarding node.

Optionally, the traffic statistics collection policy is carried in a BGPFlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec protocol packet carries the first command and thesecond command.

Optionally, the processor 1001 may further perform the followingoperations of receiving statistics collection result report informationsent by the forwarding node, where the statistics collection resultreport information carries an interface identifier of a targetinterface, the traffic identifier of the target data flow, and thetraffic statistics collection result corresponding to the trafficidentifier, and the target interface is an interface that is on theforwarding node and that is configured to forward the target packet, andrecording the traffic statistics collection result corresponding to thetraffic identifier as a traffic statistics collection result of thetarget data flow based on the statistics collection result reportinformation.

Optionally, the statistics collection result report information iscarried in a first BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the statistics collection result reportinformation is written in a length field of the statistics collectionresult report information, and the interface identifier, the trafficidentifier, and the traffic statistics collection result correspondingto the traffic identifier are written in a value field of the statisticscollection result report information.

Optionally, the processor 1001 may further perform the followingoperation of receiving first interface report information sent by theforwarding node, where the first interface report information carries aninterface identifier of a target interface and an interface name of thetarget interface, and the target interface is an interface that is onthe forwarding node and that is configured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thefirst interface report information, and the interface identifier and theinterface name are written in a value field of the first interfacereport information.

Optionally, the processor 1001 may further perform the followingoperation of receiving second interface report information sent by theforwarding node, where the second interface report information carriesan interface identifier of the target interface and interfacedescription information of the target interface, and the targetinterface is an interface that is on the forwarding node and that isconfigured to forward the target packet.

The second interface report information is carried in a third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the third optional information, and the interfaceidentifier and the interface description information are written in avalue field of the second interface report information.

FIG. 11 is a schematic structural diagram of a network device 1100according to an embodiment of the application. The forwarding node inthe embodiment shown in FIG. 6 is deployed in the network device 1100 inthis embodiment, and the network device 1100 may be configured toperform the method in the embodiment shown in FIG. 6. The network device1100 includes a processor 1101, a memory 1102, a network interface 1103,and a bus system 1104.

The bus system 1104 is configured to couple all hardware components ofthe network device 1100 together.

The network interface 1103 is configured to implement a communicationconnection between the network device 1100 and at least one othernetwork element through the Internet, a wide area network, a local areanetwork, a metropolitan area network, or another manner.

The memory 1102 is configured to store a program instruction, operatingsystem, and data.

The processor 1101 is configured to read the instruction and the datathat are stored in the memory 1102 in order to perform the followingoperations of receiving a traffic statistics collection policy sent by acontrol node, where the traffic statistics collection policy carries amatching identifier of a target data flow, a first command, and a secondcommand, the traffic statistics collection policy is generated by thecontrol node according to a statistics collection instruction, and thestatistics collection instruction is used to instruct to collect trafficstatistics of the target data flow, setting a traffic identifier for thetarget data flow based on the first command and the matching identifier,and adding, based on the second command, traffic generated by a targetpacket to a traffic statistics collection result corresponding to thetraffic identifier.

The target packet belongs to the target data flow, and the trafficstatistics collection result corresponding to the traffic identifier isused to describe the traffic of the target data flow.

Optionally, the traffic statistics collection policy is carried in a BGPFlowSpec protocol packet, NLRI of the BGP FlowSpec protocol packetcarries the matching identifier, and an extended community attribute ofthe BGP FlowSpec carries the first command and the second command.

Optionally, to set the traffic identifier for the target data flow, theprocessor 1101 may perform the following operations of searching for aforwarding entry corresponding to the matching identifier, and using theforwarding entry corresponding to the matching identifier as aforwarding entry corresponding to the target data flow, and applying, tothe forwarding entry corresponding to the target data flow, the trafficidentifier indicated by the first command.

Optionally, the processor 1101 may further perform the followingoperation of sending statistics collection result report information tothe control node, where the statistics collection result reportinformation carries an interface identifier of a target interface, thetraffic identifier of the target data flow, and the traffic statisticscollection result corresponding to the traffic identifier, and thetarget interface is an interface that is on the forwarding node and thatis configured to forward the target packet.

Optionally, the statistics collection result report information iscarried in a first BGP-LS protocol packet.

Optionally, the statistics collection result report information is in aTLV format. A type value used to indicate traffic statistics collectionis written in a type field of the statistics collection result reportinformation, a length value of the statistics collection result reportinformation is written in a length field of the statistics collectionresult report information, and the interface identifier, the trafficidentifier, and the traffic statistics collection result correspondingto the traffic identifier are written in a value field of the statisticscollection result report information.

Optionally, the processor 1101 may further perform the followingoperation of sending first interface report information to the controlnode, where the first interface report information carries an interfaceidentifier of a target interface and an interface name of the targetinterface, and the target interface is an interface that is on theforwarding node and that is configured to forward the target packet.

The first interface report information is carried in a second BGP-LSprotocol packet.

Optionally, the first interface report information is in a TLV format. Atype value used to indicate the interface name is written in a typefield of the first interface report information, a length value of thefirst interface report information is written in a length field of thefirst interface report information, and the interface identifier and theinterface name of the target interface are written in a value field ofthe first interface report information.

Optionally, the processor 1101 may further perform the followingoperation of sending second interface report information to the controlnode, where the second interface report information carries an interfaceidentifier of a target interface and interface description informationof the target interface, and the target interface is an interface thatis on the forwarding node and that is configured to forward the targetpacket.

The second interface report information is carried in the third BGP-LSprotocol packet.

Optionally, the second interface report information is in a TLV format.A type value used to indicate the interface description information iswritten in a type field of the second interface report information, alength value of the second interface report information is written in alength field of the third optional information, and the interfaceidentifier and the interface description information are written in avalue field of the second interface report information.

The word “first” in names such as the “first BGP-LS protocol packet” andthe “first optional information” mentioned in the embodiments of theapplication is merely used as a name identifier, and does not mean beingthe first in a sequence. This rule is also applicable to the word“second,” “third,” and the like.

It should be noted that the processor in the embodiments of theapplication may be an integrated circuit chip and has a signalprocessing capability. In an implementation process, steps in theforegoing methods can be implemented using a hardware integrated logicalcircuit in the processor, or using instructions in a form of software.These instructions may be implemented and controlled through cooperationof the processor, and are used to perform the methods disclosed in theembodiments of the application. The processor may be a general purposeprocessor, a digital signal processor (DSP), an application-specificintegrated circuit, a field programmable gate array (FPGA) or anotherprogrammable logical device, a discrete gate or transistor logic device,or a discrete hardware component.

The general purpose processor may be a microprocessor or the processormay be any conventional processor, decoder, or the like. The steps ofthe method disclosed with reference to the embodiments of theapplication may be directly performed by a hardware processor, or may beperformed using a combination of hardware in the processor and asoftware module. A software module may be located in a mature storagemedium in the art, such as a random access memory, a flash memory, aread-only memory, a programmable read-only memory, an electricallyerasable programmable memory, a register, or the like.

In addition, it should be noted that the bus system may further includea power bus, a control bus, a status signal bus, and the like, inaddition to a data bus. However, for clear description, various types ofbuses in FIG. 8 and FIG. 9 are marked as the bus system.

From the foregoing descriptions of the implementations, a person skilledin the art may clearly understand that some or all steps of the methodsin the embodiments may be implemented by software in addition to auniversal hardware platform. Based on such an understanding, thetechnical solutions of the application essentially or the partcontributing to the other approaches may be implemented in a form of asoftware product. The software product may be stored in a storagemedium, such as a read-only memory (ROM)/random access memory (RAM), amagnetic disk, or an optical disc, and includes several instructions forinstructing a computer device (which may be a personal computer, aserver, or a network device such as media gateway) to perform themethods described in the embodiments or some parts of the embodiments ofthe application.

It should be noted that the embodiments in this specification are alldescribed in a progressive manner, for same or similar parts in theembodiments, reference may be made to these embodiments, and eachembodiment focuses on a difference from other embodiments. Especially,method and apparatus embodiments are basically similar to a systemembodiment, and therefore is described briefly. For related parts, referto partial descriptions in the system embodiment. The described deviceand system embodiments are merely examples. The modules described asseparate parts may or may not be physically separate, and partsdisplayed as modules may or may not be physical modules, may be locatedin one position, or may be distributed on a plurality of network units.Some or all the modules may be selected based on actual requirements toachieve the objectives of the solutions of the embodiments. A person ofordinary skill in the art may understand and implement the embodimentsof the application without creative efforts.

The foregoing descriptions are merely example implementations of theapplication, but are not intended to limit the protection scope of theapplication. It should be noted that a person of ordinary skill in theart may make certain improvements and polishing without departing fromthe principle of the application and the improvements and polishingshall fall within the protection scope of the application.

1. A control method for collecting traffic statistics, comprising:obtaining, by a control node, a statistics collection instructioninstructing to collect traffic statistics of a target data flow;generating, by the control node, a traffic statistics collection policyaccording to the statistics collection instruction, the trafficstatistics collection policy a matching identifier of the target dataflow, a first command, and a second command, the first commandinstructing a forwarding node to set a traffic identifier for the targetdata flow based on the matching identifier, the second commandinstructing the forwarding node to add traffic generated by a targetpacket to a traffic statistics collection result corresponding to thetraffic identifier, the target packet belonging to the target data flow,and the traffic statistics collection result corresponding to thetraffic identifier describing traffic of the target data flow; andsending, by the control node, the traffic statistics collection policyto the forwarding node.
 2. The method of claim 1, wherein the trafficstatistics collection policy is carried in a Border Gateway ProtocolFlow Specification (BGP FlowSpec) protocol packet, network layerreachability information of the BGP FlowSpec protocol packet carryingthe matching identifier, and an extended community attribute of the BGPFlowSpec protocol packet carrying the first command and the secondcommand.
 3. The method of claim 1, further comprising: receiving, by thecontrol node, statistics collection result report information from theforwarding node, the statistics collection result report informationcarrying an interface identifier of a target interface, the trafficidentifier of the target data flow, and the traffic statisticscollection result corresponding to the traffic identifier, and thetarget interface being an interface on the forwarding node configured toforward the target packet; and recording, by the control node, thetraffic statistics collection result corresponding to the trafficidentifier as a traffic statistics collection result of the target dataflow based on the statistics collection result report information. 4.The method of claim 3, wherein the statistics collection result reportinformation is carried in a first Border Gateway Protocol-Link State(BGP-LS) protocol packet.
 5. The method of claim 1, further comprisingreceiving, by the control node, first interface report information sentfrom the forwarding node, the first interface report informationcarrying an interface identifier of a target interface and an interfacename of the target interface, the target interface being an interface onthe forwarding node configured to forward the target packet, and thefirst interface report information being carried in a second BorderGateway Protocol-Link State (BGP-LS) protocol packet.
 6. The method ofclaim 1, further comprising receiving, by the control node, secondinterface report information from the forwarding node, the secondinterface report information carrying an interface identifier of atarget interface and interface description information of the targetinterface, the target interface being an interface on the forwardingnode configured to forward the target packet, and the second interfacereport information being carried in a third Border Gateway Protocol-LinkState (BGP-LS) protocol packet.
 7. A control method for collectingtraffic statistics, comprising: receiving, by a forwarding node, atraffic statistics collection policy from a control node, the trafficstatistics collection policy carrying a matching identifier of a targetdata flow, a first command, and a second command, the traffic statisticscollection policy being generated by the control node according to astatistics collection instruction, and the statistics collectioninstruction instructing to collect traffic statistics of the target dataflow; setting, by the forwarding node, a traffic identifier for thetarget data flow based on the first command and the matching identifier;and adding, by the forwarding node based on the second command, trafficgenerated by a target packet to a traffic statistics collection resultcorresponding to the traffic identifier, the target packet belonging tothe target data flow, and the traffic statistics collection resultcorresponding to the traffic identifier describing traffic of the targetdata flow.
 8. A control apparatus for collecting traffic statistics, acontrol node being deployed in the control apparatus, and the controlapparatus comprising: a non-transitory memory storage comprisinginstructions; and one or more processors coupled to the non-transitorymemory storage, the instructions causing the one or more processors tobe configured to: obtain a statistics collection instruction instructingto collect traffic statistics of a target data flow; generate a trafficstatistics collection policy according to the statistics collectioninstruction, the traffic statistics collection policy comprising amatching identifier of the target data flow, a first command, and asecond command, the first command instructing a forwarding node to set atraffic identifier for the target data flow based on the matchingidentifier, the second command instructing the forwarding node to addtraffic generated by a target packet to a traffic statistics collectionresult corresponding to the traffic identifier, the target packetbelonging to the target data flow, and the traffic statistics collectionresult corresponding to the traffic identifier describing traffic of thetarget data flow; and send the traffic statistics collection policy tothe forwarding node.
 9. The apparatus of claim 8, wherein the trafficstatistics collection policy is carried in a Border Gateway ProtocolFlow Specification (BGP FlowSpec) protocol packet, network layerreachability information of the BGP FlowSpec protocol packet carryingthe matching identifier, and an extended community attribute of the BGPFlowSpec protocol packet carrying the first command and the secondcommand.
 10. The apparatus of claim 8, wherein the instructions furthercause the one or more processor to be configured to: receive statisticscollection result report information from the forwarding node, thestatistics collection result report information carrying an interfaceidentifier of a target interface, the traffic identifier of the targetdata flow, and the traffic statistics collection result corresponding tothe traffic identifier, and the target interface being an interface onthe forwarding node configured to forward the target packet; and recordthe traffic statistics collection result corresponding to the trafficidentifier as a traffic statistics collection result of the target dataflow based on the statistics collection result report information. 11.The apparatus of claim 10, wherein the statistics collection resultreport information is carried in a first Border Gateway Protocol-LinkState (BGP-LS) protocol packet.
 12. The apparatus of claim 8, whereinthe instructions further cause the one or more processors to beconfigured to receive first interface report information from theforwarding node, the first interface report information carrying aninterface identifier of a target interface and an interface name of thetarget interface, the target interface being an interface on theforwarding node configured to forward the target packet, and the firstinterface report information being carried in a second Border GatewayProtocol-Link State (BGP-LS) protocol packet.
 13. The apparatusaccording to claim 8, wherein the instructions further cause the one ormore processors to be configured to receive second interface reportinformation by from the forwarding node, the second interface reportinformation carrying an interface identifier of a target interface andinterface description information of the target interface, the targetinterface being an interface on the forwarding node configured toforward the target packet, and the second interface report informationbeing carried in a third Border Gateway Protocol-Link State (BGP-LS)protocol packet.
 14. A control apparatus for collecting trafficstatistics, a forwarding node being deployed in the control apparatus,and the control apparatus comprising: a non-transitory memory storagecomprising instructions; and one or more processors coupled to thenon-transitory memory storage, the instructions causing the one or moreprocessors to be configured to: receive a traffic statistics collectionpolicy from a control node, the traffic statistics collection policycarrying a matching identifier of a target data flow, a first command,and a second command, the traffic statistics collection policy beinggenerated by the control node according to a statistics collectioninstruction, and the statistics collection instruction instructing tocollect traffic statistics of the target data flow; set a trafficidentifier for the target data flow based on the first command and thematching identifier; and add, based on the second command, trafficgenerated by a target packet to a traffic statistics collection resultcorresponding to the traffic identifier, the target packet belonging tothe target data flow, and the traffic statistics collection resultcorresponding to the traffic identifier is describing traffic of thetarget data flow.
 15. The apparatus of claim 14, wherein the trafficstatistics collection policy is carried in a Border Gateway ProtocolFlow Specification (BGP FlowSpec) protocol packet, network layerreachability information of the BGP FlowSpec protocol packet carryingthe matching identifier, and an extended community attribute of the BGPFlowSpec protocol packet carrying the first command and the secondcommand.
 16. The apparatus of claim 14, wherein the instructions furthercause the one or more processors to be configured to: search for aforwarding entry corresponding to the matching identifier; set theforwarding entry corresponding to the matching identifier as aforwarding entry corresponding to the target data flow; and apply, tothe forwarding entry corresponding to the target data flow, the trafficidentifier indicated by the first command.
 17. The apparatus of claim14, wherein the instructions further cause the one or more processors tobe configured to send statistics collection result report information tothe control node, the statistics collection result report informationcarrying an interface identifier of a target interface, the trafficidentifier of the target data flow, and the traffic statisticscollection result corresponding to the traffic identifier, and thetarget interface being an interface on the forwarding node configured toforward the target packet.
 18. The apparatus of claim 17, wherein thestatistics collection result report information is carried in a firstBorder Gateway Protocol-Link State (BGP-LS) protocol packet.
 19. Theapparatus of claim 14, wherein the instructions further cause the one ormore processors to be configured to send first interface reportinformation to the control node, the first interface report informationcarrying an interface identifier of a target interface and an interfacename of the target interface, the target interface an interface on theforwarding node configured to forward the target packet, and the firstinterface report information being carried in a second Border GatewayProtocol-Link State (BGP-LS) protocol packet.
 20. The apparatus of claim14, wherein the instructions further cause the one or more processors tobe configured to send second interface report information to the controlnode, the second interface report information carrying an interfaceidentifier of a target interface and interface description informationof the target interface, the target interface being an interface on theforwarding node configured to forward the target packet, and the secondinterface report information being carried in a third Border GatewayProtocol-Link State (BGP-LS) protocol packet.
 21. A control system forcollecting traffic statistics, comprising: a first network deviceconfigured to: obtain a statistics collection instruction instructing tocollect traffic statistics of a target data flow; generate a trafficstatistics collection policy according to the statistics collectioninstruction, the traffic statistics collection policy comprising amatching identifier of the target data flow, a first command, and asecond command, the first command instructing a forwarding node to set atraffic identifier for the target data flow based on the matchingidentifier, the second command instructing the forwarding node to addtraffic generated by a target packet to a traffic statistics collectionresult corresponding to the traffic identifier, the target packetbelonging to the target data flow, and the traffic statistics collectionresult corresponding to the traffic identifier describing traffic of thetarget data flow; and send the traffic statistics collection policy tothe forwarding node; and a second network device coupled to the firstnetwork device and configured to: receive the traffic statisticscollection policy from a control node, the traffic statistics collectionpolicy carrying the matching identifier of the target data flow, thefirst command, and the second command, the traffic statistics collectionpolicy being generated by the control node according to the statisticscollection instruction, and the statistics collection instructioninstructing to collect the traffic statistics of the target data flow;set the traffic identifier for the target data flow based on the firstcommand and the matching identifier; and add, based on the secondcommand, the traffic generated by the target packet to the trafficstatistics collection result corresponding to the traffic identifier.